package com.com01迭代器模式.test;

import java.util.ArrayList;
import java.util.List;

public class BookListImpl implements BookList{
    private List<Book> bookList = null;

    public BookListImpl(int maxSize) {
        this.bookList = new ArrayList<>(maxSize);
    }

    @Override
    public Iterator getIterator() {
        // new 对象只能创建实例化对象
        return new IteratorBookImpl(this);
    }
    public Book getElement(int index) {
        return  bookList.get(index);
    }
    public int getLength() {
        return bookList.size();
    }
    @Override
    public void addElement(Book o) {
        bookList.add(o);
    }
}
